package com.pty.demo.creational;

import lombok.Getter;
import lombok.Setter;

/**
 * @author pengty
 * @date 2020/3/11
 */
@Getter
@Setter
public class BuilderPattern {

    private String code;

    private String name;

    private String addr;

    public BuilderPattern(String code, String name, String addr) {
        this.code = code;
        this.name = name;
        this.addr = addr;
    }

    public static BuilderPattern.Builder builder = new BuilderPattern.Builder();

    public static class Builder {
        private String code;

        private String name;

        private String addr;

        public Builder code(String code) {
            this.code = code;
            return this;
        }

        public Builder name(String name) {
            this.name = name;
            return this;
        }

        public Builder addr(String addr) {
            this.addr = addr;
            return this;
        }

        public BuilderPattern build() {
            return new BuilderPattern(code, name, addr);
        }
    }

}
